<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <book v-for="item in list" v-bind:name="item.name" v-bind:author="item.author"></book>
    </div>

    <script>

        //创建组件 Vue下的方法 component: ƒ ( id, definition )
        Vue.component("book", {
            // data() {
            //     return {
            //         name: "三体",
            //         author: "刘慈溪"
            //     }
            // },
            props:["name","author"],
            template: `
            <div style="border:1px solid red">
                <p>{{name}}</p>
                <p>作者：{{author}}</p>
            </div>
            `
        });
        var app = new Vue({
            el: "#app",
            data:{
                list:[
                {
                        name:"小明",
                        author:"小明"
                    },
                    {
                        author:"小明",
                        name:"小熊"

                    },
                    {
                        author:"小明",
                        name:"小潇"
                    },
                    {
                        author:"小明",
                        name:"小华"
                    }
                ]
            }
        });
    </script>
</body>

</html>